﻿@model Amazon.Checkout.ViewModels.TaxTableListViewModel

@{ Layout.Title = T("Manage Tax Tables").ToString(); }

@Html.ValidationSummary()
@using (Html.BeginFormAntiForgeryPost())
{   
    <div class="manage">@Html.ActionLink(T("Create New Tax Table").ToString(), "New", new { }, new { @class = "button primaryAction" })</div>
    
    <fieldset>
        <table class="items" summary="@T("Available Tax tables.")">
            <colgroup>
                <col id="Col1" />
                <col id="Col2" />
                <col id="Col3" />
                <col id="Col4" />
                <col id="Col5" />
            </colgroup>
            
            <thead>
                <tr>
                    <th scope="col">&nbsp;&darr;</th>
                    <th scope="col">@T("Tax Table Name")</th>
                    <th scope="col">@T("Number Of Tax Rules")</th>
                    <th scope="col">@T("Actions")</th>
                </tr>
            </thead>

            @if (Model.TaxTables.Any())
            {
                foreach (var taxTable in Model.TaxTables)
                {
                    var totalRules = (@taxTable.Taxes ?? string.Empty).Split(',')
                                                                 .Where(t => !string.IsNullOrEmpty(t.Trim()))
                                                                 .Count();
                    <tr>
                        <td><input type="checkbox" value="true" name="@T("Checkbox.{0}", taxTable.Id)"/></td>                
                        <td>@Html.ActionLink(taxTable.Name, "Edit", new { taxTableId = @taxTable.Id })</td>
                        <td>@totalRules</td>
                        <td>
                            @Html.ActionLink("Edit", "Edit", new { taxTableId = @taxTable.Id }) |
                            @Html.ActionLink("Delete", "Delete", new { taxTableId = @taxTable.Id }) 
                        </td>
                    </tr>
                }
            }
            else
            {
                <tr class="no-records">
                    <td colspan="4">There are no tax tables created.</td>
                </tr>   
            }
        </table>
    </fieldset>
}
